home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / quicktime / streaming / qtstreammsg / qtstreammsg.c < prev    next >
Encoding:
Text File  |  2000-09-28  |  3.6 KB  |  118 lines

  1. //////////
  2. //
  3. //    File:        QTStreamMsg.c
  4. //
  5. //    Contains:    Sample code for intercepting and issuing messages to the streaming controller bar.
  6. //
  7. //    Written by:    Tim Monroe
  8. //
  9. //    Copyright:    © 1999 by Apple Computer, Inc., all rights reserved.
  10. //
  11. //    Change History (most recent first):
  12. //
  13. //       <1>         06/11/99    rtm        first file
  14. //
  15. //
  16. //    The movie controller indicates the status of streaming operations by sending action messages to itself.
  17. //    You can intercept those messages in your movie controller action filter procedure by intercepting messages
  18. //    of type mcActionShowStatusString. The parameter data is a pointer to a structure of type QTStatusStringRecord,
  19. //    which is defined like this:
  20. //    
  21. //    struct QTStatusStringRecord {
  22. //        long                         stringTypeFlags;
  23. //        char *                        statusString;
  24. //    };
  25. //    
  26. //    You can identify streaming-specific messages by inspecting the stringTypeFlags field; if the bit
  27. //    kStatusStringIsStreamingStatus is set, then the message pertains to streaming operations. In addition, if the bit
  28. //    kStatusHasCodeNumber is set, then the high-order 16 bits of the stringTypeFlags field contain a result code. 
  29. //    
  30. //    The statusString field contains the actual text of the status message, which (if you do nothing to it) will be
  31. //    displayed in the controller bar status area. You can (if you like) suppress the display of the message or change
  32. //    the message to some other message.
  33. //    
  34. //////////
  35.  
  36. #include "QTStreamMsg.h"
  37.  
  38. char                *gMessageArray[] = MESSAGE_ARRAY;        // array of substitute messages
  39. char                gStreamingMessage[kMaxMessageSize];        
  40.  
  41.  
  42. //////////
  43. //
  44. // QTStreamMsg_IssueMessage
  45. // Display the specified message in the controller bar of the streaming movie controlled by theMC.
  46. //
  47. //////////
  48.  
  49. void QTStreamMsg_IssueMessage (MovieController theMC, char *theMessage)
  50. {
  51.     QTStatusStringRecord    myRecord;
  52.     
  53.     myRecord.stringTypeFlags = kStatusStringIsStreamingStatus;
  54.     myRecord.statusString = theMessage;
  55.     
  56.     MCDoAction(theMC, mcActionShowStatusString, &myRecord);
  57. }
  58.  
  59.  
  60. //////////
  61. //
  62. // QTStreamMsg_ActionFilterProc 
  63. // Intercept some messages for the streaming movie movie controller.
  64. //
  65. // For the purposes of this sample code, we will interpret theRefCon as a Boolean value that indicates
  66. // whether to suppress the display of the messages.
  67. //
  68. //////////
  69.  
  70. PASCAL_RTN Boolean QTStreamMsg_ActionFilterProc (MovieController theMC, short theAction, void *theParams, long theRefCon)
  71. {
  72. #pragma unused(theMC)
  73.  
  74.     Boolean            isHandled = false;            // false => allow controller to process the action
  75.     Boolean            isSuppressed = (Boolean)theRefCon;
  76.     
  77.     switch (theAction) {
  78.         
  79.         case mcActionShowStatusString: {
  80.             QTStatusStringPtr        myStatusPtr = (QTStatusStringPtr)theParams;
  81.         
  82.             // make sure it's a streaming status message
  83.             if (!(myStatusPtr->stringTypeFlags & kStatusStringIsStreamingStatus))
  84.                 break;
  85.             
  86.             // save the original message for our application's own use elsewhere
  87.             if (strlen(myStatusPtr->statusString) > 0)
  88.                 strcpy(gStreamingMessage, myStatusPtr->statusString);
  89.             
  90.             // intercept "Connecting", "Negotiating", and "Buffering" and substitute other messages
  91.             if (strcmp(myStatusPtr->statusString, "Connecting") == 0)
  92.                 myStatusPtr->statusString = gMessageArray[kConnectingMsgIndex];
  93.         
  94.             if (strcmp(myStatusPtr->statusString, "Negotiating") == 0)
  95.                 myStatusPtr->statusString = gMessageArray[kNegotiatingMsgIndex];
  96.         
  97.             if (strcmp(myStatusPtr->statusString, "Buffering") == 0)
  98.                 myStatusPtr->statusString = gMessageArray[kBufferingMsgIndex];
  99.         
  100.             if (isSuppressed)
  101.                 isHandled = true;
  102.                 
  103.             break;
  104.         }
  105.         
  106.         // handle other mcAction messages here
  107.         
  108.         default:
  109.             break;
  110.             
  111.     }    // switch (theAction)
  112.     
  113.     return(isHandled);    
  114. }
  115.  
  116.  
  117.  
  118.